#Loop Demo - For more information see Ch 6 - http://www.openbookproject.net/thinkcs/python/english2e/ch06.xhtml
import time

#Example 1: Simple While Loop
print "While Loop Example 1:\n"


count = 0
while count < 10:
    print "This is great!"
    count += 1                   #adds 1 to the current value of count, same as count = count + 1

raw_input("Press <enter> to continue...")

#Example 2: Another simple loop - print '\t' inserts a "TAB" in the output.  Useful for printing tables.
print "While Loop Example 2:\n"
x = 1
while x < 13:
    print x, '\t', 2**x
    x += 1

raw_input("Press <enter> to continue...")

#Example 3:  Loop based on user input
print "While Loop Example 3:\n"

choice = ""
while choice != "secret":
    choice = raw_input("Type the word I'm thinking: ")

raw_input("Press <enter> to continue...")


#Example 4: make a character move across the screen
print "While Loop Example 4:\n"

i = 0
while i<=40:
    print '\b'*(i+2),   #what is \b????  That "prints" a backspace key erasing what characters were there
    print " "*i+"o",
    i += 1    
    time.sleep(0.1)

    
##Some things to try:
##
##1. Change Example 2 to count down instead of up.
##2. Change Example 3 to move backwards instead of forwards.  What about making it move back and forth?
##3. Given the examples in this file, which is example would help you in altering the Temperature 
##   Conversion program to prompt the user repeatedly until they wanted to quit?  Try it!
##4. Implement a number guessing game in that the computer picks a random number and the user tries repeatedly
##   to guess the number.  On each guess, the computer tells you whether your guess is higher or low than the random
##    number
##   Here's the code for generating a random number between 1 and 100:
##        import random
##        rand_num = random.randint(1,100)
   